import type { TableColumn } from '@/components/core/dynamic-table';
import { router } from '@/router';

export type TableListItem = API.SiteKyjcrwListPageResult;
export type TableColumnItem = TableColumn<TableListItem>;

const caseStatus = (val) => {
  switch (val) {
    case 1:
      return '立案';
    case 2:
      return '调查取证';
    case 3:
      return '案件处理';
    case 4:
      return '结案归档';
    case 5:
      return '案件终止';
    case 6:
      return '已结束';
    default:
      return '-';
  }
};

export const kyjcrwCoumns: TableColumn[] = [
  {
    title: '案件编号',
    width: 80,
    dataIndex: 'caseCode',
    hideInSearch: true,
  },
  {
    title: '案件来源',
    width: 60,
    dataIndex: 'sourceName',
    hideInSearch: true,
  },
  {
    title: '案由',
    dataIndex: 'caseActionName',
    width: 60,
    hideInSearch: true,
  },
  {
    title: '执法机构',
    width: 60,
    dataIndex: 'agencyName',
    hideInSearch: true,
  },
  {
    title: '案件状态',
    width: 60,
    dataIndex: 'status',
    hideInSearch: true,
    customRender: ({ record }) => caseStatus(record.status),
  },
  {
    title: '执法人员',
    width: 60,
    dataIndex: 'createUser',
    hideInSearch: true,
  },
  {
    title: '提交时间',
    width: 60,
    dataIndex: 'createTime',
    hideInSearch: true,
  },
  {
    title: '操作',
    width: 80,
    dataIndex: 'ACTION',
    align: 'center',
    fixed: 'right',
    actions: ({ record }) => [
      {
        label: '详情',
        onClick: () =>
          router.push({
            name: 'administrative-penalty-caseView',
            query: { id: record.id, status: record.status },
          }),
      },
    ],
  },
];
